package com.ibeetl.admin.core.service;


import com.ibeetl.admin.core.dao.CoreZanDao;
import com.ibeetl.admin.core.entity.CoreZan;



import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;

import org.beetl.sql.core.annotatoin.Param;
import org.beetl.sql.core.annotatoin.Sql;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;






/**
 * 点赞 Service
 */

@Service
@Transactional
public class CoreZanService extends CoreBaseService<CoreZan>{

    @Autowired private CoreZanDao coreZanDao;

    public PageQuery<CoreZan>queryByCondition(PageQuery query){
        PageQuery ret =  coreZanDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelCoreZan(List<Long> ids){
        try {
            coreZanDao.batchDelCoreZanByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除点赞失败", e);
        }
    }
    
    
    //获取某个文章的点赞数
    public Integer getZanByArticleId(Long articleId, String type) {
    	return this.coreZanDao.getZanByArticleId(articleId);
    }
    
    //某个时间段IP地址的点赞数
    public Integer validateZan(@Param(value="article_id")Long articleId, @Param(value="create_time")String createTime, @Param(value="ip")String ip, @Param(value="type")String type) {
    	return this.coreZanDao.validateZan(articleId, createTime, ip, type);
    }
    
  //某个时间段IP地址的点赞数
    public Integer validateZan(@Param(value="article_id")Long articleId, @Param(value="create_time")String createTime, @Param(value="ip")String ip, @Param(value="type")String type, @Param(value="userId")Long userId) {
    	return this.coreZanDao.validateZan(articleId, createTime, ip, type, userId);
    }
}